package game.ui.controls
{
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import game.ui.core.*;
	
	public class RxBusyIndicator extends RxUIElement
	{
		private var m_icon:RxBitmap;
		private var m_labelField:RxTextLabel;
		private var m_iconContainer:Sprite;
		private var m_labelPlacement:String;
		private static const HORIZONTAL_PADDING:int = 0;
		
		public function RxBusyIndicator(param1:String = "ui/icons/throbber.png")
		{
			m_measuredWidth = 32;
			m_measuredHeight = 32;
			this.m_labelPlacement = RxUIPositionConstants.BOTTOM;
			this.m_iconContainer = new Sprite();
			addChild(this.m_iconContainer);
			this.m_icon = new RxBitmap();
			this.m_icon.addEventListener(Event.COMPLETE, this.OnBusyIndicatorLoaded);
			this.m_iconContainer.addChild(this.m_icon);
			this.SetIconUrl(param1);
			InvalidateSize();
		}
		
		public function SetIconUrl(param1:String) : void
		{
			if (this.m_labelField)
			{
				this.m_labelField.visible = false;
			}
			this.m_icon.visible = false;
			this.m_icon.url = param1;
		}
		
		protected function OnBusyIndicatorLoaded(event:Event) : void
		{
			this.m_icon.removeEventListener(Event.COMPLETE, this.OnBusyIndicatorLoaded);
			InvalidateSize();
		}
		
		public function Start() : void
		{
			RxUI.AddElementToUpdateQueue(this);
			this.m_icon.visible = true;
			InvalidateSize();
			this.UpdateDisplayState();
			if (this.m_labelField)
			{
				this.m_labelField.visible = true;
			}
		}
	}
}